home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / STRINGS.SWG / 0055_Replace portion of STRING.pas < prev    next >
Pascal/Delphi Source File  |  1993-09-26  |  921b  |  23 lines

  1. {*****************************************************************************
  2.  * Function ...... StrTran()
  3.  * Purpose ....... To replace portions of a string
  4.  * Parameters .... Source          Master string to do the replace in
  5.  *                 Old             Portion to replace
  6.  *                 New             New portion to replace <old> with
  7.  * Returns ....... Source with all occurances of <old> replaced with <new>
  8.  * Notes ......... None
  9.  * Author ........ Martin Richardson
  10.  * Date .......... May 13, 1992
  11.  *****************************************************************************}
  12. FUNCTION StrTran( Source, Old, New : STRING ) : STRING;
  13. VAR p : INTEGER;
  14. BEGIN
  15.      WHILE POS( Old, Source ) <> 0 DO BEGIN
  16.            p := POS( Old, Source );
  17.            DELETE( Source, p, LENGTH( Old ) );
  18.            INSERT( New, Source, p );
  19.      {W}END;
  20.      StrTran := Source;
  21. END; { StrTran }
  22.  
  23.